package com.ruoyi.system.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.SysContractLogMapper;
import com.ruoyi.system.domain.SysContractLog;
import com.ruoyi.system.service.ISysContractLogService;

/**
 * 合同操作日志Service业务层处理
 *
 * @author ruoyi
 * @date 2025-06-24
 */
@Service
public class SysContractLogServiceImpl implements ISysContractLogService
{
    @Autowired
    private SysContractLogMapper sysContractLogMapper;

    /**
     * 查询合同操作日志
     *
     * @param id 合同操作日志主键
     * @return 合同操作日志
     */
    @Override
    public SysContractLog selectSysContractLogById(Long id)
    {
        return sysContractLogMapper.selectSysContractLogById(id);
    }

    /**
     * 查询合同操作日志列表
     *
     * @param sysContractLog 合同操作日志
     * @return 合同操作日志
     */
    @Override
    public List<SysContractLog> selectSysContractLogList(SysContractLog sysContractLog)
    {
        return sysContractLogMapper.selectSysContractLogList(sysContractLog);
    }

    /**
     * 根据合同日志查询合同日志
     * @param contractId
     * @return
     */
    @Override
    public List<SysContractLog> selectSysContractLogListByContractId(Long contractId) {
        return sysContractLogMapper.selectSysContractLogListByContractId(contractId);
    }

    /**
     * 新增合同操作日志
     *
     * @param sysContractLog 合同操作日志
     * @return 结果
     */
    @Override
    public int insertSysContractLog(SysContractLog sysContractLog)
    {
        sysContractLog.setCreateTime(DateUtils.getNowDate());
        return sysContractLogMapper.insertSysContractLog(sysContractLog);
    }

    /**
     * 构建合同日志实体
     * @param contractId
     * @param operate
     * @return
     */
    @Override
    public SysContractLog buildSysContractLog(Long contractId, String operate) {
        SysContractLog sysContractLog = new SysContractLog();
        //创建人
        sysContractLog.setCreateBy("admin");
        //sysContractLog.setCreateBy(SecurityUtils.getUsername());
        //创建时间
        sysContractLog.setCreateTime(DateUtils.getNowDate());
        //操作
        sysContractLog.setOperate(operate);
        //日志主键
        sysContractLog.setContractId(contractId);
        return sysContractLog;
    }

    /**
     * 修改合同操作日志
     *
     * @param sysContractLog 合同操作日志
     * @return 结果
     */
    @Override
    public int updateSysContractLog(SysContractLog sysContractLog)
    {
        return sysContractLogMapper.updateSysContractLog(sysContractLog);
    }

    /**
     * 批量删除合同操作日志
     *
     * @param ids 需要删除的合同操作日志主键
     * @return 结果
     */
    @Override
    public int deleteSysContractLogByIds(Long[] ids)
    {
        return sysContractLogMapper.deleteSysContractLogByIds(ids);
    }

    /**
     * 删除合同操作日志信息
     *
     * @param id 合同操作日志主键
     * @return 结果
     */
    @Override
    public int deleteSysContractLogById(Long id)
    {
        return sysContractLogMapper.deleteSysContractLogById(id);
    }

    /**
     * 根据合同主键删除合同日志
     * @param contractId
     * @return
     */
    @Override
    public int deleteSysContractLogByContractId(Long contractId) {
        return sysContractLogMapper.deleteSysContractLogByContractId(contractId);
    }
}